<!DOCTYPE html>
<html>
<head>
<title>编辑文章</title>
#include("../include/common.html")
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>编辑文章</h5>
            </div>
           <form id="inputForm" action="update" method="post">
                <input type="hidden" name="id" value="#(article.id)" />
                <div class="ibox-content">
                    <div class="form-horizontal clearfix">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">标题：</label>
                            <div class="col-sm-3">
                                <input class="form-control" type="text" name="title" value="#(article.title)">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">分类：</label>
                            <div class="col-sm-3">
                               <select class="form-control" name="articleCategoryId">
                                    <option value="">请选择</option>
                                    #for(articleCategoryItem : articleCategoryTree)
                                        <option value="#(articleCategoryItem.id)" #if(articleCategoryItem.id == article.articleCategoryId) selected="selected" #end>
                                            #if(articleCategoryItem.grade != 0)
                                                #for(i = 0; i < articleCategoryItem.grade; i++)
                                                    &nbsp;&nbsp;
                                                #end
                                            #end
                                            #(articleCategoryItem.name)
                                        </option>
                                    #end
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">图片：</label>
                            <div class="col-sm-3" id="fileImage">
                                 #if(article.image??)
                                 <img alt="" src="#(imageUrl(article.image))" height="110"><input type="hidden" name="image" value="#(article.image)"/>
                                 #end
                             </div>
                             <div class="col-sm-3">
                                 <a href="javascript:;" id="filePicker" class="btn btn-primary">选择文件</a>
                             </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">作者：</label>
                            <div class="col-sm-3">
                                <input class="form-control" type="text" name="author" value="#(article.author)">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">设置：</label>
                            <div class="col-sm-3">
                                <div class="checkbox">
                                   <label class="m-r"><input type="checkbox" name="isPublication" value="true" #if(article.isPublication) checked="checked" #end/>发布</label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">内容：</label>
                            <div class="col-sm-8">
                               <textarea id="content" name="content" class="ibox-content no-padding" style="height: 250px;">#(article.content)</textarea>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer col-sm-3 col-sm-offset-2">
                    <button type="submit" class="btn btn-w-m btn-primary">确定</button>
                    <button type="button" class="btn btn-w-m btn-default" onclick="history.back(); return false;">取消</button>
                </div>
            </form>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
function fileUploadCall(fromType,url){
	var html='<img alt="" src="'+url+'" height="110"><input type="hidden" name="image" value="'+url+'"/>';
	$("#fileImage").html(html);
}
$().ready(function() {

    var $inputForm = $("#inputForm");
    var $content = $("#content");
    
    var $filePicker = $("#filePicker");
    
    $content.editor();

    $filePicker.uploader();
    
    // 表单验证
    $inputForm.validate({
        rules: {
            title: "required",
            articleCategoryId: "required"
        }
    });

});
</script>